<template>
    <div>
        <el-row style="font-size:16px;text-align:center;color: #495060;padding: 30px 150px;margin-top: 20px;">
            请选择需要创建的应用类型
        </el-row>

        <el-row class="sep">
            <div class="item" v-for="item in templates" :key="item.id">
                <div class="item-title clearfix wsc_bg" :style="{backgroundColor: item.color, backgroundImage: 'none'}">
                    <div class="name">
                        {{item.name}}
                    </div>
                    <div class="cir icon" :style="{backgroundImage: `url(${item.img_url})`}"></div>
                </div>
                <div class="desc">
                    <div class="desc-content">
                        {{item.info}}
                        <a :href="item.info_url" v-if="item.info_url" rel="noopener noreferrer" target="_blank" class="link">了解更多</a>
                    </div>

                    <el-button type="ghost" v-if="item.online && item.open_url" @click="openApp(item)" class="btn">立即开通</el-button>
                    <div v-if="item.online && item.open_url" style="position: absolute;bottom:-26px;text-align:center;width:165px;color:#80848f">
                        <el-button type="ghost" disabled="disabled" style="border: 0" v-if="!item.online" class="btn">敬请期待</el-button>
                    </div>

                </div>
            </div>
        </el-row>

        <el-row>
            <div style="text-align: center;
    color: #495060;
    margin-top: 100px;
    margin-bottom: 50px;
    font-size: 16px;">不知道选哪个？欢迎拨打开店咨询热线：0371-63337761</div>
        </el-row>

    </div>
</template>

<script>
export default {
    data() {
        return {
            templates: []
        };
    },
    async asyncData({ app }) {
        let data = {};

        const template = await app.$axios.$get("/api/app/home/app/template");
        if (template && template.errmsg === "ok") {
            data.templates = template.data;
        }

        return data;
    },
    methods: {
        async openApp(item) {
            if (this.isHttpUrl(item.open_url)) {
                window.open(item.open_url, "_self");
            } else {
                this.$router.push({
                    path: item.open_url,
                    query: { id: item.id }
                });
            }
        }
    }
};
</script>

<style scoped>
.sep {
    margin-left: -48px;
    display: -webkit-box;
    display: -webkit-flex;
    display: -moz-box;
    display: -ms-flexbox;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sep .item:first-child {
    margin-left: 50px;
}

.sep .item {
    width: 210px;
    height: 316px;
    position: relative;
    margin-left: 20px;
}

.sep .item .item-title {
    height: 124px;
    text-align: center;
    position: relative;
}

.sep .item .wsc_bg {
    background-color: #fe6156;
    background-image: -webkit-gradient(
        linear,
        left top,
        left bottom,
        from(#fe6156),
        color-stop(98%, #f11b0b)
    );
    background-image: -webkit-linear-gradient(top, #fe6156, #f11b0b 98%);
    background-image: -moz-linear-gradient(top, #fe6156 0, #f11b0b 98%);
    background-image: linear-gradient(-180deg, #fe6156, #f11b0b 98%);
}

.sep .item .desc {
    padding: 30px 20px 0;
    display: -webkit-box;
    display: -webkit-flex;
    display: -moz-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    padding-bottom: 10px;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    -moz-box-orient: vertical;
    -moz-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: start;
    -webkit-align-items: flex-start;
    -moz-box-align: start;
    -ms-flex-align: start;
    align-items: flex-start;
    border: 1px solid #e5e5e5;
    border-top: 0;
    font-size: 12px;
    text-align: left;
    height: 226px;
    background-color: #fff;
}

.sep .item .item-title .name {
    padding-top: 30px;
    font-size: 16px;
    color: #fff;
}

.sep .item .item-title .wsc {
    background-image: url(https://img.yzcdn.cn/wsc/shop/choose/wsc1.png);
}

.sep .item .item-title .icon {
    width: 128px;
    height: 52px;
    position: absolute;
    bottom: 0;
    left: 50%;
    margin-left: -64px;
    background-size: 100% 100%;
    background-position: bottom;
}

.sep .item .desc .desc-content {
    color: #666;
}

.sep .item .btn {
    width: 136px;
    height: 36px;
    font-size: 12px;
    position: absolute;
    bottom: 0;
    left: 50%;
    margin-left: -68px;
    color: #39f;
    background-color: transparent;
    border-color: #39f;
    border-radius: 0;
}

.sep .item .btn:hover {
    color: #5cadff;
    border-color: #5cadff;
}

.sep .item .desc .desc-content .link {
    margin-left: 8px;
}

.sep .item .weizhan {
    background-color: #0590fc;
    background-image: -webkit-gradient(
        linear,
        left top,
        left bottom,
        from(#0590fc),
        to(#1b58e5)
    );
    background-image: -webkit-linear-gradient(top, #0590fc, #1b58e5);
    background-image: -moz-linear-gradient(top, #0590fc 0, #1b58e5 100%);
    background-image: linear-gradient(-180deg, #0590fc, #1b58e5);
}
</style>
